<?php
    session_start();

    include ('normalizeData.php');
    if(mb_strlen($username) > 3 and mb_strlen($username) < 21 and mb_strlen($password) > 3 and mb_strlen($password) < 11)
    {
        $infoToAdd = $username.'|'.$password.PHP_EOL;
        $fileName = 'usernamesAndPasswords.txt';
        file_put_contents($fileName, $infoToAdd, FILE_APPEND);
        $_SESSION['message'] = 'Your new username and password have been added!';
    }
    else
    {
        $_SESSION['message'] = 'The username or password are not in the right format, try again!';
    }

    header('Location: registerForm.php');
?>